This example uses a COM component included in the IDL distribution. The RSIDemoComponent is included purely for demonstration purposes, and does not perform any useful work beyond illustrating how IDLcomIDispatch objects are created and used.
The RSIDemoComponent is contained in a file named RSIDemoComponent.dll located in the examples\doc\bridges\COM subdirectory of the IDL distribution. Before attempting to execute this example, make sure the component is registered on your system as described in Registering COM Components on a Windows Machine.
There are three objects defined by the RSIDemoComponent. The example begins by using RSIDemoObj1, which has the program ID:
RSIDemoComponent.RSIDemoObj1
and the class ID:
{A77BC2B2-88EC-4D2A-B2B3-F556ACB52E52}
Note: This complete example, IDispatchDemo.pro, is located in the examples\doc\bridges\COM subdirectory of the IDL distribution. It develops an IDL procedure called IDispatchDemo that illustrates use of the RSIDemoComponent. Run the example procedure by entering IDispatchDemo at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT IDispatchDemo.pro.
obj1 = OBJ_NEW( $
'IDLCOMIDispatch$PROGID$RSIDemoComponent_RSIDemoObj1')
or (with Class ID):
obj1 = OBJ_NEW( $
'IDLCOMIDispatch$CLSID$A77BC2B2_88EC_4D2A_B2B3_F556ACB52E52')
strCLSID = obj1->GetCLSID()
PRINT, strCLSID
Note: The GetCLSID method returns the class identifier of the object using the standard COM separators ( - ).
obj1 -> GetProperty, MessageStr = outStr
PRINT, outStr
IDL should print 'RSIDemoObj1'.
obj1 -> SetProperty, MessageStr = 'Hello, world'
obj1 -> DisplayMessageStr
instr = 'The value is: '
val = 25L
outStr = obj1->Msg2InParams(instr, val)
PRINT, outStr
HELP, obj1, /OBJECTS
Note: If the index is not 1, 2, or 3, the GetIndexObject method will return an error.
To get a reference to RSIDemoObj3, use the following command:
obj3 = obj1->GetIndexObject(3)
obj3CLSID = obj3->GetCLSID()
PRINT, obj3CLSID
OBJ_DESTROY, obj3
objs = obj1->GetArrayOfObjects(cItems)
PRINT, cItems
FOR i = 0, cItems-1 do begin
objCLSID = objs[i] -> GetCLSID()
PRINT, 'Object[',i,'] CLSID: ', objCLSID
ENDFOR
OBJ_DESTROY, objs
OBJ_DESTROY, obj1